import {
  wfBusiTypeTree,
  wfBusiTypeSelect,
  wfBusiTypeInsert,
  wfBusiTypeUpdateById,
  wfBusiTypeDelete,
  wfBusiTypeProcessOrgTree,
  wfBusiTypeProcessSelect,
  wfBusiTypeProcessInsert,
  wfBusiTypeProcessUpdateById,
  wfBusiTypeProcessDelete,
  wfBusiProcButtonAll,
  wfBusiProcActSelect,
  wfBusiProcButtonSelect,
  wfBusiProcButtonInsert,
  wfBusiProcButtonDelete
} from '@/api/workFlowManage/busiWorkFlowConfig'

import {
  wfBizCategoryTree,
  wfBizCategorySelect,
  wfBizCategoryInsert,
  wfBizCategoryUpdateById,
  wfBizCategoryDelete,
  wfProcessSelect,
  wfProcessSelectByCateId,
  wfProcessDelete,
  wfProcessActive,
  wfProcessCopy,
  wfProcessChangeCategory,
  wfProcessExport
} from '@/api/workFlowManage/workFlowDefine'

import {
  wfProcessToDoList,
  wfProcessHasToDoList,
  wfProcessAgentToDoList,
  wfProcessAgentHasToDoList,
  wfProcessToDoAll,
  wfProcessHasToDoAll,
  wfProcessMonitor,
  wfProcessAuditHistory,
  wfBusiProcessList,
  wfBusiProcActListForSubmit,
  wfBusiProcActAuditBtn,
  wfBusiProcAddSigner,
  wfBusiProcAddSignerPass,
  wfBusiProcAddSignerReject,
  wfBusiProcActListForAudit,
  // wfBusiProcAuditPass,
  wfBusiProcActListForReject,
  wfBusiProcRejectBySendToFree,
  // wfBusiProcReject,
  // wfBusiProcRushToSign,
  // wfBusiProcApplyWithdraw,
  wfBusiProcAuditWithdrawEnable,
  wfBusiProcAuditWithdraw,
  wfBusiProcViewToDo,
  wfProcessIsExistToBeDone
} from '@/api/workFlowManage/workFlowInstance'

import {
  sysCodeListByCodeType,
  wfBusiDemoSelect,
  wfBusiDemoInsert,
  wfBusiDemoUpdateById,
  wfBusiDemoDelete,
  wfBusiDemoSubmit,
  wfBusiDemoPass,
  wfBusiDemoReject,
  wfBusiDemoApplyWithdraw,
  wfBusiDemoRushToSign,
  wfBusiDemoRead
} from '@/api/workFlowManage/busiWorkFlowDemo'

const workFlowManage = {
  actions: {
    // 获取系统码表
    SysCodeListByCodeType({ commit }, args) {
      return new Promise((resolve, reject) => {
        sysCodeListByCodeType(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取业务类型树形结构
    WfBusiTypeTree({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiTypeTree(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 查询业务类型
    WfBusiTypeSelect({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiTypeSelect(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 插入业务类型
    WfBusiTypeInsert({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiTypeInsert(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 更新业务类型（通过主键ID）
    WfBusiTypeUpdateById({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiTypeUpdateById(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 删除业务类型（通过主键ID）
    WfBusiTypeDelete({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiTypeDelete(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取机构树形结构
    WfBusiTypeProcessOrgTree({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiTypeProcessOrgTree(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取业务已经关联的流程
    WfBusiTypeProcessSelect({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiTypeProcessSelect(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 插入业务关联的流程
    WfBusiTypeProcessInsert({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiTypeProcessInsert(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 更新业务关联的流程
    WfBusiTypeProcessUpdateById({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiTypeProcessUpdateById(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 删除业务关联的流程
    WfBusiTypeProcessDelete({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiTypeProcessDelete(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 查询所有可用按钮
    WfBusiProcButtonAll({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcButtonAll(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 查询所有可用按钮
    WfBusiProcActSelect({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcActSelect(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 查询已配置按钮按钮
    WfBusiProcButtonSelect({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcButtonSelect(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 保存配置按钮按钮
    WfBusiProcButtonInsert({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcButtonInsert(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 删除已配置按钮按钮
    WfBusiProcButtonDelete({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcButtonDelete(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取流程分类树形结构
    WfBizCategoryTree({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBizCategoryTree(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 查询流程分类
    WfBizCategorySelect({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBizCategorySelect(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 插入流程分类
    WfBizCategoryInsert({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBizCategoryInsert(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 更新流程分类（通过主键ID）
    WfBizCategoryUpdateById({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBizCategoryUpdateById(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 删除流程分类（通过主键ID）
    WfBizCategoryDelete({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBizCategoryDelete(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取流程
    WfProcessSelect({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessSelect(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取流程（通过流程分类）
    WfProcessSelectByCateId({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessSelectByCateId(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 流程删除
    WfProcessDelete({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessDelete(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 流程激活
    WfProcessActive({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessActive(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 流程复制
    WfProcessCopy({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessCopy(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 流程分类更改
    WfProcessChangeCategory({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessChangeCategory(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 流程导出
    WfProcessExport({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessExport(args)
      })
    },

    // 工作流我的待办
    WfProcessToDoList({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessToDoList(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流我的已办
    WfProcessHasToDoList({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessHasToDoList(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流代理待办
    WfProcessAgentToDoList({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessAgentToDoList(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流代理已办
    WfProcessAgentHasToDoList({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessAgentHasToDoList(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流待办所有
    WfProcessToDoAll({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessToDoAll(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流已办所有
    WfProcessHasToDoAll({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessHasToDoAll(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 流程运行情况查看
    WfProcessMonitor({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessMonitor(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 流程审核历史
    WfProcessAuditHistory({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessAuditHistory(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 查询业务绑定流程列表
    WfBusiProcessList({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcessList(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 查询业务绑定流程环节列表
    WfBusiProcActListForSubmit({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcActListForSubmit(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 工作流业务示例查询
    WfBusiDemoSelect({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiDemoSelect(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流业务示例插入
    WfBusiDemoInsert({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiDemoInsert(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流业务示例更新
    WfBusiDemoUpdateById({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiDemoUpdateById(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流业务示例删除
    WfBusiDemoDelete({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiDemoDelete(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流业务示例提交
    WfBusiDemoSubmit({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiDemoSubmit(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流业务示例通过
    WfBusiDemoPass({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiDemoPass(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流业务示例驳回
    WfBusiDemoReject({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiDemoReject(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流业务示例撤回
    WfBusiDemoApplyWithdraw({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiDemoApplyWithdraw(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流业务示例抢签
    WfBusiDemoRushToSign({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiDemoRushToSign(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 工作流业务示例已阅
    WfBusiDemoRead({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiDemoRead(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 获取审核按钮列表
    WfBusiProcActAuditBtn({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcActAuditBtn(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 判断工作项是否未被审核完成
    WfProcessIsExistToBeDone({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfProcessIsExistToBeDone(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },

    // 前加签
    WfBusiProcAddSigner({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcAddSigner(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 加签通过
    WfBusiProcAddSignerPass({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcAddSignerPass(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 加签驳回
    WfBusiProcAddSignerReject({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcAddSignerReject(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 审核时，获取下一环节列表
    WfBusiProcActListForAudit({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcActListForAudit(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // // 审核通过
    // WfBusiProcAuditPass({ commit }, args) {
    //   return new Promise((resolve, reject) => {
    //     wfBusiProcAuditPass(args).then(response => {
    //       resolve(response.data)
    //     }).catch(error => {
    //       reject(error)
    //     })
    //   })
    // },
    // 选择节点驳回时，获取下一环节列表
    WfBusiProcActListForReject({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcActListForReject(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 选择节点驳回
    WfBusiProcRejectBySendToFree({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcRejectBySendToFree(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 整体驳回（流程终止）
    // WfBusiProcReject({ commit }, args) {
    //   return new Promise((resolve, reject) => {
    //     wfBusiProcReject(args).then(response => {
    //       resolve(response.data)
    //     }).catch(error => {
    //       reject(error)
    //     })
    //   })
    // },
    // 抢签
    // WfBusiProcRushToSign({ commit }, args) {
    //   return new Promise((resolve, reject) => {
    //     wfBusiProcRushToSign(args).then(response => {
    //       resolve(response.data)
    //     }).catch(error => {
    //       reject(error)
    //     })
    //   })
    // },
    // // 单据撤回（申请人撤回）
    // WfBusiProcApplyWithdraw({ commit }, args) {
    //   return new Promise((resolve, reject) => {
    //     wfBusiProcApplyWithdraw(args).then(response => {
    //       resolve(response.data)
    //     }).catch(error => {
    //       reject(error)
    //     })
    //   })
    // },
    // 审核人是否可撤回
    WfBusiProcAuditWithdrawEnable({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcAuditWithdrawEnable(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 审核人撤回
    WfBusiProcAuditWithdraw({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcAuditWithdraw(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 更新待办为已读
    WfBusiProcViewToDo({ commit }, args) {
      return new Promise((resolve, reject) => {
        wfBusiProcViewToDo(args).then(response => {
          resolve(response.data)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default workFlowManage
